import './styles/LayoutStyles.scss'
// import 'virtual:svg-icons-register'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import './styles/index.scss'
import App from './App.vue'
import router from './router'
import { setupPrimeVuePlugins } from './plugins/primevue'
import { scrollbarPlugin } from './plugins/scrollbar'
import { setupI18n } from './locales'

// 异步加载 SVG 图标
const loadSvgIcons = async () => {
  await import('virtual:svg-icons-register')
}

const app = createApp(App)
app.use(createPinia().use(piniaPluginPersistedstate))
setupPrimeVuePlugins(app)
app.use(scrollbarPlugin)
setupI18n(app)
app.use(router)
app.mount('#app')

// SVG 图标在应用启动时一次性注册导致的性能问题
// 在应用挂载后加载图标,异步加载 SVG 图标
requestIdleCallback(() => {
  loadSvgIcons()
})
